﻿using UnityEngine;
using System.Collections;

public class TrailScript : MonoBehaviour {

	public float lifetime = 4;
	public bool StartScreen = false;

	// Use this for initialization
	void Start () 
	{
		Material newMat = new Material(renderer.material);
		newMat.CopyPropertiesFromMaterial(renderer.material);
		renderer.material = newMat;
	}
	
	// Update is called once per frame
	void Update () 
	{
		if(StartScreen) return;

		lifetime -= Time.deltaTime;

		if(lifetime < 0)
		{
			Destroy(transform.gameObject);
		}

		float fade = Mathf.Min(1, lifetime);
		Color newColor = renderer.material.color;
		newColor.a = lifetime;
		renderer.material.color = newColor;



	}





}
